var PointClass = (function () {
    function PointClass(_x, _y) {
        var _this = this;
        this._x = _x;
        this._y = _y;
        this.drawPoint = function () {
            console.log("x: ", _this._x, "y: ", _this._y);
        };
        this.getDistances = function (p) {
            return Math.pow(p.X - _this._x, 2) + Math.pow(p.Y - _this._y, 2);
        };
    }
    Object.defineProperty(PointClass.prototype, "X", {
        get: function () {
            return this._x;
        },
        set: function (value) {
            if (value < 0) {
                throw new Error("x的value不能小于0");
            }
            this._x = value;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PointClass.prototype, "Y", {
        get: function () {
            return this._y;
        },
        set: function (value) {
            if (value < 0) {
                throw new Error("y的value不能小于0");
            }
            this._y = value;
        },
        enumerable: false,
        configurable: true
    });
    return PointClass;
}());
var point = new PointClass(1, 2);
point.X = 10;
point.Y = 20;
console.log(point.X);
console.log(point.drawPoint());
var point2 = new PointClass(110, 120);
console.log(point.getDistances(point2));
